<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>8、使用ssh方式部署博客 | haijd</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  
  <meta name="keywords" content="Hexo博客搭建" />
  
  
  
  
  <meta name="description" content="Hexo博客搭建">
<meta name="keywords" content="Hexo博客搭建">
<meta property="og:type" content="article">
<meta property="og:title" content="8、使用SSH方式部署博客">
<meta property="og:url" content="http://www.hais2.com/2016/05/14/Hexo-Getting-Started-1/index.html">
<meta property="og:site_name" content="haijd">
<meta property="og:description" content="Hexo博客搭建">
<meta property="og:locale" content="default">
<meta property="og:image" content="http://ww3.sinaimg.cn/mw690/c55a7aeegw1f3uan23rrbj20ys0akjse.jpg">
<meta property="og:image" content="http://ww4.sinaimg.cn/mw690/c55a7aeegw1f3uapehmq5j20u70bgmxr.jpg">
<meta property="og:image" content="http://ww3.sinaimg.cn/mw690/c55a7aeegw1f3uatkjjpgj20x00d80tx.jpg">
<meta property="og:image" content="http://ww2.sinaimg.cn/mw690/c55a7aeegw1f3uaxsq545j20uc074wf7.jpg">
<meta property="og:image" content="http://ww3.sinaimg.cn/mw690/c55a7aeegw1f3uaym7h35j20v002t74d.jpg">
<meta property="og:updated_time" content="2017-08-02T15:22:33.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="8、使用SSH方式部署博客">
<meta name="twitter:description" content="Hexo博客搭建">
<meta name="twitter:image" content="http://ww3.sinaimg.cn/mw690/c55a7aeegw1f3uan23rrbj20ys0akjse.jpg">
  
    <link rel="alternate" href="/atom.xml" title="haijd" type="application/atom+xml">
  
  <link rel="icon" href="/css/images/favicon.ico">
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link href="https://fonts.googleapis.com/css?family=Open+Sans|Montserrat:700" rel="stylesheet" type="text/css">
  <link href="https://fonts.googleapis.com/css?family=Roboto:400,300,300italic,400italic" rel="stylesheet" type="text/css">
  <link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
  <style type="text/css">
    @font-face{font-family:futura-pt;src:url(https://use.typekit.net/af/9749f0/00000000000000000001008f/27/l?subset_id=2&fvd=n5) format("woff2");font-weight:500;font-style:normal;}
    @font-face{font-family:futura-pt;src:url(https://use.typekit.net/af/90cf9f/000000000000000000010091/27/l?subset_id=2&fvd=n7) format("woff2");font-weight:500;font-style:normal;}
    @font-face{font-family:futura-pt;src:url(https://use.typekit.net/af/8a5494/000000000000000000013365/27/l?subset_id=2&fvd=n4) format("woff2");font-weight:lighter;font-style:normal;}
    @font-face{font-family:futura-pt;src:url(https://use.typekit.net/af/d337d8/000000000000000000010095/27/l?subset_id=2&fvd=i4) format("woff2");font-weight:400;font-style:italic;}</style>
    
  <link rel="stylesheet" id="athemes-headings-fonts-css" href="//fonts.googleapis.com/css?family=Yanone+Kaffeesatz%3A200%2C300%2C400%2C700&amp;ver=4.6.1" type="text/css" media="all">
  <link rel="stylesheet" href="/css/style.css">

  <script src="/js/jquery-3.1.1.min.js"></script>

  <!-- Bootstrap core CSS -->
  <link rel="stylesheet" href="/css/bootstrap.css" >
  <link rel="stylesheet" href="/css/hiero.css" >
  <link rel="stylesheet" href="/css/glyphs.css" >
  
    <link rel="stylesheet" href="/css/vdonate.css" >
  

</head>

<script>
var themeMenus = {};

  themeMenus["/"] = "Home"; 

  themeMenus["/archives"] = "Archives"; 

  themeMenus["/categories"] = "Categories"; 

  themeMenus["/tags"] = "Tags"; 

  themeMenus["/about"] = "About"; 

</script>


  <body data-spy="scroll" data-target="#toc" data-offset="50">


  <header id="allheader" class="site-header" role="banner">
  <div class="clearfix container">
      <div class="site-branding">

          <h1 class="site-title">
            
              <a href="/" title="haijd" rel="home"> haijd </a>
            
          </h1>

          
            <div class="site-description">Stay Hungry,Stay Foolish</div>
          
            
          <nav id="main-navigation" class="main-navigation" role="navigation">
            <a class="nav-open">Menu</a>
            <a class="nav-close">Close</a>
            <div class="clearfix sf-menu">

              <ul id="main-nav" class="nmenu sf-js-enabled">
                    
                      <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-1663"> <a class="" href="/">Home</a> </li>
                    
                      <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-1663"> <a class="" href="/archives">Archives</a> </li>
                    
                      <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-1663"> <a class="" href="/categories">Categories</a> </li>
                    
                      <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-1663"> <a class="" href="/tags">Tags</a> </li>
                    
                      <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-1663"> <a class="" href="/about">About</a> </li>
                    
              </ul>
            </div>
          </nav>


      </div>
  </div>
</header>




  <div id="container">
    <div id="wrap">
            
      <div id="content" class="outer">
        
          <section id="main" style="float:none;"><article id="post-Hexo-Getting-Started-1" style="width: 66%; float:left;" class="article article-type-post" itemscope itemprop="blogPost" >
  <div id="articleInner" class="clearfix post-1016 post type-post status-publish format-standard has-post-thumbnail hentry category-template-2 category-uncategorized tag-codex tag-edge-case tag-featured-image tag-image tag-template">
    
    
      <header class="article-header">
        
  
    <h1 class="thumb" class="article-title" itemprop="name">
      8、使用SSH方式部署博客
    </h1>
  

      </header>
    
    <div class="article-meta">
      
	Posted on <a href="/2016/05/14/Hexo-Getting-Started-1/" class="article-date">
	  <time datetime="2016-05-13T17:35:24.000Z" itemprop="datePublished">May 14, 2016</time>
	</a>

      
	<span id="busuanzi_container_page_pv">
	  本文总阅读量<span id="busuanzi_value_page_pv"></span>次
	</span>

    </div>
    <div class="article-entry" itemprop="articleBody">
      
        <p>　　每次写完博客提交都要输入账号密码，尤其是同时部署到了俩网站，输两个网站的账号密码，简直噩梦一般，这篇就是为了解除这个噩梦。</p>
<h2 id="什么是SSH"><a href="#什么是SSH" class="headerlink" title="什么是SSH"></a>什么是SSH</h2><p>　　简单说就是一种更加安全的网络传输协议。摘录一段维基百科的解释：</p>
<blockquote>
<p>Secure Shell（缩写为SSH），由IETF的网络工作小组（Network Working Group）所制定；SSH为一项创建在应用层和传输层基础上的安全协议，为计算机上的Shell（壳层）提供安全的传输和使用环境。<br>传统的网络服务程序，如rsh、FTP、POP和Telnet其本质上都是不安全的；因为它们在网络上用明文传送数据、用户帐号和用户口令，很容易受到中间人（man-in-the-middle）攻击方式的攻击。就是存在另一个人或者一台机器冒充真正的服务器接收用户传给服务器的数据，然后再冒充用户把数据传给真正的服务器。<br>而SSH是目前较可靠，专为远程登录会话和其他网络服务提供安全性的协议。利用SSH协议可以有效防止远程管理过程中的信息泄露问题。通过SSH可以对所有传输的数据进行加密，也能够防止DNS欺骗和IP欺骗。<br>SSH之另一项优点为其传输的数据可以是经过压缩的，所以可以加快传输的速度。SSH有很多功能，它既可以代替Telnet，又可以为FTP、POP、甚至为PPP提供一个安全的“通道”。</p>
</blockquote>
<h2 id="创建SSH"><a href="#创建SSH" class="headerlink" title="创建SSH"></a>创建SSH</h2><ol>
<li><p>检查电脑上是否创建了SSH key<br>　　右键打开Git Bash，输入下面的命令，检查“.ssh”文件夹中是否已经创建了id_rsa id_rsa.pub known_hosts文件。<a id="more"></a></p>
<figure class="highlight jboss-cli"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">cd</span> ~<span class="string">/.ssh</span></span><br><span class="line"><span class="keyword">ls</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>创建SSH key<br>　　执行下面命令</p>
<figure class="highlight excel"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh-keygen -<span class="built_in">t</span> rsa -C <span class="string">"@你的邮箱.com"</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>一路回车，直到最后。</p>
</li>
<li>进入个人文件夹，找到进入“.ssh”文件夹，使用编辑器打开<code>id_rsa.pub</code>文件，全选复制里面的内容。</li>
</ol>
<h2 id="将SSH添加到github和coding"><a href="#将SSH添加到github和coding" class="headerlink" title="将SSH添加到github和coding"></a>将SSH添加到github和coding</h2><p><strong>github</strong></p>
<ol>
<li>登陆你的github账户，进入个人账户设置界面。<img src="http://ww3.sinaimg.cn/mw690/c55a7aeegw1f3uan23rrbj20ys0akjse.jpg" alt=""></li>
<li>将复制的内容，粘贴到“Key”框里面，Title随意填写。确认保存。<img src="http://ww4.sinaimg.cn/mw690/c55a7aeegw1f3uapehmq5j20u70bgmxr.jpg" alt=""><br><strong>coding</strong></li>
<li>登陆你的coding账户，进入账户设置=&gt;SHH公钥，填写赋值的内容保存。<img src="http://ww3.sinaimg.cn/mw690/c55a7aeegw1f3uatkjjpgj20x00d80tx.jpg" alt=""></li>
</ol>
<h2 id="将博客的部署方式改为SSH方式"><a href="#将博客的部署方式改为SSH方式" class="headerlink" title="将博客的部署方式改为SSH方式"></a>将博客的部署方式改为SSH方式</h2><ol>
<li>进入github和coding里你的博客项目，复制SSH地址。<img src="http://ww2.sinaimg.cn/mw690/c55a7aeegw1f3uaxsq545j20uc074wf7.jpg" alt=""><br><img src="http://ww3.sinaimg.cn/mw690/c55a7aeegw1f3uaym7h35j20v002t74d.jpg" alt=""></li>
<li>打开博客文件夹根目录下的<code>_config.yml</code>文件，修改<code>deploy</code>节点，将两个地址分别改为你的博客项目的SSH地址,例如：<figure class="highlight less"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">deploy</span>:</span><br><span class="line">  <span class="attribute">type</span>: git</span><br><span class="line">  <span class="attribute">message</span>: <span class="string">""</span></span><br><span class="line">  <span class="attribute">repo</span>: </span><br><span class="line">    <span class="attribute">github</span>: git<span class="variable">@github</span>.<span class="attribute">com</span>:haijiandong/haijiandong.github.io.git,master</span><br><span class="line">    <span class="attribute">gitcafe</span>: git<span class="variable">@git</span>.coding.<span class="attribute">net</span>:Is2/Is2.git,coding-pages</span><br></pre></td></tr></table></figure>
</li>
</ol>
<p>现在可以试一下了，改完第一次部署会让输入yes/no，输完yes之后，你会发现瞬间麻烦就没有了，可以安心写博客了。</p>

      
    </div>
    <footer class="entry-meta entry-footer">
      
	<span class="ico-folder"></span>
    <a class="article-category-link" href="/categories/Hexo/">Hexo</a>

      
  <span class="ico-tags"></span>
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Hexo博客搭建/">Hexo博客搭建</a></li></ul>

      
        <div id="donation_div"></div>

<script src="/js/vdonate.js"></script>
<script>
var a = new Donate({
  title: '如果觉得我的文章对您有用，请随意打赏。您的支持将鼓励我继续创作!', // 可选参数，打赏标题
  btnText: 'Donate', // 可选参数，打赏按钮文字
  el: document.getElementById('donation_div'),
  wechatImage: '/css/images/wechatPay.png',
  alipayImage: '/css/images/alipay.jpg'
});
</script>
      

      
        
	<section id="comments" class="comment">
	  <div id="disqus_thread">
	  <noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
	  </div>
	</section>

	<script type="text/javascript">
	var disqus_shortname = 'haijdblog';
	(function(){
	  var dsq = document.createElement('script');
	  dsq.type = 'text/javascript';
	  dsq.async = true;
	  dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
	  (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
	}());
	(function(){
	  var dsq = document.createElement('script');
	  dsq.type = 'text/javascript';
	  dsq.async = true;
	  dsq.src = '//' + disqus_shortname + '.disqus.com/count.js';
	  (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
	}());
	</script>


      
    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2016/07/17/Fiddler-caught-analysis-API/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          使用Fiddler抓包分析API
        
      </div>
    </a>
  
  
    <a href="/2016/05/14/Hexo-Getting-Started-7/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">7、解析博客域名</div>
    </a>
  
</nav>

  
</article>

<!-- Table of Contents -->

  <aside id="sidebar">
    <div id="toc" class="toc-article">
    <strong class="toc-title">Contents</strong>
    
      <ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#什么是SSH"><span class="nav-number">1.</span> <span class="nav-text">什么是SSH</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#创建SSH"><span class="nav-number">2.</span> <span class="nav-text">创建SSH</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#将SSH添加到github和coding"><span class="nav-number">3.</span> <span class="nav-text">将SSH添加到github和coding</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#将博客的部署方式改为SSH方式"><span class="nav-number">4.</span> <span class="nav-text">将博客的部署方式改为SSH方式</span></a></li></ol>
    
    </div>
  </aside>
</section>
        
      </div>
      <footer id="footer" class="site-footer">
  

  <div class="clearfix container">
      <div class="site-info">
	      &copy; 2018 haijd All Rights Reserved.
          
            <span id="busuanzi_container_site_uv">
              本站访客数<span id="busuanzi_value_site_uv"></span>人次  
              本站总访问量<span id="busuanzi_value_site_pv"></span>次
            </span>
          
      </div>
      <div class="site-credit">
        Theme by <a href="https://github.com/iTimeTraveler/hexo-theme-hiero" target="_blank">hiero</a>
      </div>
  </div>
</footer>


<!-- min height -->

<script>
    var contentdiv = document.getElementById("content");

    contentdiv.style.minHeight = document.body.offsetHeight - document.getElementById("allheader").offsetHeight - document.getElementById("footer").offsetHeight + "px";
</script>
    </div>
    <!-- <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
    <a href="/categories" class="mobile-nav-link">Categories</a>
  
    <a href="/tags" class="mobile-nav-link">Tags</a>
  
    <a href="/about" class="mobile-nav-link">About</a>
  
</nav> -->
    

<!-- mathjax config similar to math.stackexchange -->

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    tex2jax: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      processEscapes: true
    }
  });
</script>

<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
      tex2jax: {
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
    });
</script>

<script type="text/x-mathjax-config">
    MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for(i=0; i < all.length; i += 1) {
            all[i].SourceElement().parentNode.className += ' has-jax';
        }
    });
</script>

<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/scripts.js"></script>
<script src="/js/bootstrap.js"></script>
<script src="/js/main.js"></script>








	<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
	</script>






  </div>

  <a id="rocket" href="#top" class=""></a>
  <script type="text/javascript" src="/js/totop.js" async=""></script>
</body>
</html>
